package com.lj.infoisland.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lj.infoisland.domain.po.Users;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/*
 * @description 用户mapper
 * @author 龙洁
 * @create 2024-10-21 下午10:22
 */
@Mapper
public interface UsersMapper extends BaseMapper<Users> {
    /**
     * 查询近7天的新增用户数量count
     *
     * @return
     */
    @Select("select count(*) as count from users where created_at >= date_sub(curdate(), interval 7 day)")
    Integer getNewUsersCount();

    /**
     * 查询距离当天天数的新增用户数量count
     *
     * @param i
     * @return
     */
    @Select("SELECT COUNT(*) AS count \n" +
            "FROM users \n" +
            "WHERE DATE(created_at) = DATE_SUB(CURDATE(), INTERVAL #{i} DAY);")
    Integer getWeekUserCount(int i);
}
